package cn.JHai.rbac.conf;


import cn.JHai.rbac.interceptor.LoginInterceptor;
import cn.JHai.rbac.interceptor.SecurityInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class IntercptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor checkLoginIntercptor;
    @Autowired
    private SecurityInterceptor securityInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkLoginIntercptor).
                addPathPatterns("/**").
                excludePathPatterns("/login")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/login.html");

        registry.addInterceptor(securityInterceptor).
                addPathPatterns("/**").
                excludePathPatterns("/login")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/login.html");
    }


}
